<style>
    .layui-form-label.required:before { /* 这种写法也可以*/
        content: ' *';
        color: red;
    }

    .open-form .layui-input-block{
        margin-left: 145px;
    }
    .open-form .layui-form-label {
        width: 115px;
    }

    .addProductionPlanForm-title .title, .examineProductionPlanForm-title .title {
        display: inline-block;
        margin: 20px;
        font-size: 16px;
        font-weight: bold;
        color: #333333;
        line-height: 19px;
        position: relative;
        padding: 6px 0 19px 0;
    }

    .addProductionPlanForm-title .title:after, .examineProductionPlanForm-title .title:after {
        content: '';
        display: block;
        position: absolute;
        left: 0;
        bottom: 0;
        width: calc(100% + 6px);
        height: 3px;
        background: #0A8B0A;
    }
</style>
<script type="text/javascript" src="../../../admin/assets/js/pdfobject.min.js"></script>
<!-- 表单弹窗 -->
<form lay-filter="dayTakeGoodsFrom" class="layui-form open-form">
    <div class="open-model">
        <div class="open-auto">


            <div class="layui-form-item layui-row">

                <div class="layui-col-md3">
                    <label class="layui-form-label">记录编号：</label>
                    <div class="layui-input-block">
                        <input type="text" id="takeRecordNumber" name="takeRecordNumber" disabled class="layui-input"
                               placeholder="记录编号">
                    </div>
                </div>

                <div class="layui-col-md3">
                    <label class="layui-form-label">提货订单编号：</label>
                    <div class="layui-input-block">
                        <input type="text" id="takeOrderNumber" name="takeOrderNumber" disabled class="layui-input"
                               placeholder="提货订单编号">
                    </div>
                </div>



                <div class="layui-col-md3">
                    <label class="layui-form-label">订单来源：</label>
                    <div class="layui-input-block">
                        <input type="text" id="saveSource" name="saveSource" disabled  class="layui-input"
                               placeholder="订单来源">
                    </div>
                </div>

                <div class="layui-col-md3">
                    <label class="layui-form-label">物流数：</label>
                    <div class="layui-input-block">
                        <input type="text" id="containedMaterialCount" name="containedMaterialCount" disabled class="layui-input"
                               placeholder="物流数">
                    </div>
                </div>
            </div>





            <div class="layui-form-item layui-row">

                <div class="layui-col-md3">
                    <label class="layui-form-label">采购客户：</label>
                    <div class="layui-input-block">
                        <input type="text" id="plantCode" name="plantCode" disabled class="layui-input"
                               placeholder="采购客户">
                    </div>
                </div>

                <div class="layui-col-md3">
                    <label class="layui-form-label">所属客户：</label>
                    <div class="layui-input-block">
                        <input type="text" id="factoryName" name="factoryName" disabled class="layui-input"
                               placeholder="所属客户">
                    </div>
                </div>



          <!--      <div class="layui-col-md3">
                    <label class="layui-form-label">预测需求时间：</label>
                    <div class="layui-input-block">
                        <input type="text" id="receiveMouthDate" name="receiveMouthDate" disabled class="layui-input"
                               placeholder="预测需求时间">
                    </div>
                </div>-->



                <div class="layui-col-md3">
                    <label class="layui-form-label">添加人：</label>
                    <div class="layui-input-block">
                        <input type="text" id="creatorName" name="creatorName" disabled class="layui-input"
                               placeholder="添加人">
                    </div>
                </div>


                <div class="layui-col-md3">
                    <label class="layui-form-label">添加时间：</label>
                    <div class="layui-input-block">
                        <input type="text" id="createTime" name="createTime" disabled  class="layui-input"
                               placeholder="添加时间">
                    </div>
                </div>
            </div>



            <div class="layui-form-item layui-row">

                <div class="layui-col-md3">
                    <label class="layui-form-label">订单下单：</label>
                    <div class="layui-input-block">
                        <input type="text" id="orderCreateTime" name="orderCreateTime"  disabled class="layui-input"
                               placeholder="订单下单">
                    </div>
                </div>

                <div class="layui-col-md3">
                    <label class="layui-form-label">状态：</label>
                    <div class="layui-input-block">
                        <input type="text" id="auditStatus" name="auditStatus" disabled class="layui-input"
                               placeholder="状态">
                    </div>
                </div>

                <div class="layui-col-md3">
                    <label class="layui-form-label">审核人：</label>
                    <div class="layui-input-block">
                        <input type="text" id="auditPeople" name="auditPeople" disabled class="layui-input"
                               placeholder="审核人">
                    </div>
                </div>

                <div class="layui-col-md3">
                    <label class="layui-form-label">审核时间：</label>
                    <div class="layui-input-block">
                        <input type="text" id="auditTime" name="auditTime"  disabled class="layui-input"
                               placeholder="审核时间">
                    </div>
                </div>

            </div>

            <div class="examineProductionPlanForm-title">
                <h3 class="title">生产物料</h3>
            </div>
            <div class="layui-form-item layui-row">
                <div id="demandDay">
                    <table class="layui-table" id="requireItemTable" lay-filter="requireItemTable"></table>
                </div>
            </div>
        </div>

    </div>
</form>

<script type="text/html" id="viewAttachmentHtml">
    <div id="example1" style="height: 100%;"></div>
</script>


<!-- js部分 -->
<script>
    layui.use(['layer', 'form', 'table', 'laydate', 'admin', 'laytpl', 'upload', 'config'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var config = layui.config;
        var table = layui.table;
        var admin = layui.admin;
        var form = layui.form;
        var laydate = layui.laydate;

        let skuInfoObj = new Map()
        let planItemData = [];

        //初始化计划表
        table.render({
            elem: '#requireItemTable',
            data: planItemData,
            id: 'requireItemTable',
            page: true,
            cols: [[
                  {type: 'numbers', title: '序号', width: 80}
                , {field: 'materialCode', align: 'center', edit: 'text', title: '物料编号'}
                , {field: 'materialSimplifiedCode', align: 'center', edit: 'text', title: '物料简码'}
                , {field: 'materialDescribe', align: 'center', edit: 'text', title: '组件描述'}
                , {field: 'specsNumber', align: 'center', edit: 'text', title: '规格码'}
                , {field: 'productLine', align: 'center', edit: 'text', title: '产线'}
                , {field: 'takeGoodsCount', align: 'center', edit: 'text', title: '数量'}
                , {field: 'materialUnit', align: 'center', edit: 'text', title: '单位'}
                , {field: 'purchaseTissue', align: 'center', edit: 'text', title: '采购组织'}
                , {field: 'purchaseTissueName', align: 'center', edit: 'text', title: '采购组描述'}
                , {field: 'takeGoodsTime', align: 'center', edit: 'text', title: '提货时间'}
            ]]
        });

        table.on('rowDouble(requireItemTable)', function(obj) {
            let birthdayCell = $(obj.tr).find('.date-cell');
            laydate.render({
                elem: birthdayCell[0], // 绑定到生日单元格
                type: 'month', // 类型为月
                format: 'yyyy-MM', // 格式
                range: false, // 不允许选择范围
                done: function (value, date) {
                    obj.update({
                        planTime: value
                    });
                    // 重新加载表格数据
                    table.reload('planItemData', {
                        data: planItemData // 传入更新后的数据
                    });
                }
            });
            // 手动触发日期选择器
            birthdayCell.click();
        });

        //数据
        let tempData = admin.getTempData("dayTakeGoodsInfoData");
        if( tempData&& tempData.id != null){
            admin.req('production/productionPlan/admin/dayTakeGoods/getDayTakeGoodsDetail', {id: tempData.id}, function (res) {

                if (res.code == 200) {

                    form.val('dayTakeGoodsFrom', res.data === undefined ? null : res.data);

                    for (const resKey in res.data.dayTakeGoodsItermList) {
                        planItemData.push(res.data.dayTakeGoodsItermList[resKey]);
                    }

                    table.reload('requireItemTable', {
                        data: planItemData
                    })
                } else {
                    layer.msg(res.msg, {icon: 2});
                }
            })
        }

        laydate.render({
            elem: '#planReceiveTime'
            , type: 'datetime'
        });





    });
</script>